home *** CD-ROM | disk | FTP | other *** search
- ; DIV2
- ; Dividing by 2 using lists of n ()'s
-
- (defun create-n (n)
- (do ((n n (1- n))
- (a () (push () a)))
- ((= n 0) a)))
-
- (defvar div2-l )
- (setq div2-l (create-n 200.))
-
- (defun iterative-div2 (l)
- (do ((l l (cddr l))
- (a () (push (car l) a)))
- ((null l) a)))
-
- (defun recursive-div2 (l)
- (cond ((null l) ())
- (t (cons (car l) (recursive-div2 (cddr l))))))
-
- (defun iterative-div2-test (l)
- (do ((i 300. (1- i)))
- ((= i 0))
- (iterative-div2 l)
- (iterative-div2 l)
- (iterative-div2 l)
- (iterative-div2 l)))
-
- (defun recursive-div2-test (l)
- (do ((i 300. (1- i)))
- ((= i 0))
- (recursive-div2 l)
- (recursive-div2 l)
- (recursive-div2 l)
- (recursive-div2 l)))
-
- (define-timer div2-1 "Div2, Iterative" (iterative-div2-test div2-l))
- (qa-attempt "Div2, Iterative" (iterative-div2-test div2-l) nil)
-
- (define-timer div2-2 "Div2, Recursive" (recursive-div2-test div2-l))
- (qa-attempt "Div2, Recursive" (recursive-div2-test div2-l) nil)